package lab02.test13;

/**
 * Created by lenovo on 2017/10/20.
 */
public class Gymnastics extends ComputerAverage {

    @Override
    public double average(double[] scores) {
        double average = 0;
        double sum =0;
        double intermediary;
        //冒泡排序进行排序
        for (int j = 0;j < scores.length;j++) {
            for (int i = 0; i < scores.length - j - 1; i++) {
                if (scores[i] > scores[i + 1]) {
                    intermediary  = scores[i];
                    scores[i] = scores[i + 1];
                    scores[i + 1] = intermediary;
                }
            }
        }

        //求总分：去掉一个最低分，去掉一个最高分，然后求总分。
        for (int j = 1;j < scores.length - 1;j ++){
            sum = sum + scores[j];
        }

        //求平均分
        average = sum / (scores.length - 2);

        return average;
    }
}


